<?php
namespace app\admin\validate;

use think\Validate;

class Adminer extends Validate
{
    protected $rule = [
        'username' => 'require|length:3,18|unique:admin,username,0,id',
        'realname' => 'require',
        'password' => 'require',
    ];

    protected $message = [
        'username.require' => '用户名必须输入',
        'username.length' => '用户名需在3-18字符',
        'username.unique' => '用户名已存在',
        'realname' => '真实姓名不能为空',
        'password' => '密码不能为空',
    ];

    protected $scene = [
        'add' => ['username', 'realname', 'password'],
        'edit' => ['realname'],
    ];
//            $validate = Validate::make([
//                'username' => 'require|unique:admin_group,name,0,id',
//                'password' => 'length:6,18',
//                'confirm_password' => 'confirm:password',
//                'realname' => 'require',
//            ],
//                [
//                    'username.require' => '账号不能为空',
//                    'username.unique' => '账号已存在',
//                    'password.require' => '密码不能为空',
//                    'password.length' => '密码长度长度为6-18位',
//                    'confirm_password.require' => '确认密码不能为空',
//                    'confirm_password.confirm' => '确认密码和密码长度不一样',
//                    'realname.require' => '用户昵称不能为空',
//                ]);
//            if (!$validate->check($post)) {
//                $this->error($validate->getError());
//            }
}
